<% if(organization != null){ 
var organization_user_role_id = 0;
if (!_.isUndefined(authuser.user)) {
	var organization_user_role_id = organization.organizations_users.findWhere({
		user_id: parseInt(authuser.user.id)
	});
	if (!_.isEmpty(organization_user_role_id)) {
		organization_user_role_id = organization_user_role_id.attributes.organization_user_role_id;
	}
}
%>
<td class="col-lg-5 col-md-3 col-sm-6 col-xs-5">
	<div class="media">
		<%
			var logo_path = "img/default-organization.png";
			if (!_.isUndefined(organization.attributes.logo_url) && organization.attributes.logo_url != null) {
				logo_path = organization.showImage('Organization', organization.attributes.id, 'small_thumb' );
			}
		%>
		<a data-placement="bottom" title="<%- organization.attributes.name %>" data-toggle="tooltip" class="pull-left" href="#/organization/<%- organization.attributes.id %>"> <img alt="[Images: <%- organization.attributes.name %>]" src="<%= logo_path %>" height="32" width="32" class="img-rounded"></a>
		  <div class="media-body">
		  	<div class="clearfix">
				<a class="pull-left" href="#/organization/<%- organization.attributes.id %>"><h4 class="navbar-btn"><%- organization.attributes.name %></h4></a>
			</div>
			<% if(organization.attributes.description != ''){ %>
			<div>
				<p class="htruncate-l3"><%- organization.attributes.description%></p>
			</div>
			<%}%>
		  </div>
	</div>
</td>
<td class="text-right">
<ul class="list-inline clearfix">
	<li class="pull-right ">
		<ul class="list-inline navbar-btn clearfix">
			<li class="dropdown navbar-btn">
				<% var user_count = '';
				   if(parseInt(organization.attributes.organizations_user_count) != 0){
					user_count = parseInt(organization.attributes.organizations_user_count);
					user_count = (user_count > 1) ? 's' : '';
				   }
				%>
				<a title="<%- i18next.t('Members') %>" class="btn btn-default <% if(organization.attributes.organizations_user_count != 0){ %>dropdown-toggle<%}else{%>js-no-action<%}%>" href="#" <% if(organization.attributes.organizations_user_count != 0){ %>data-toggle="dropdown"<%}%>>
					<%- i18next.t('{{count}} Member{{user_count}}', {count: organization.attributes.organizations_user_count, user_count: user_count}) %>
				</a>
				<% if(organization.attributes.organizations_user_count != 0){ %>
					<ul class="dropdown-menu arrow arrow-left  text-left" role="boards">
						<% _.each(organization.attributes.organizations_users, function(organizations_user){%>
							<li><a href="#/user/<%-organizations_user.user_id%>"><%-organizations_user.username%></a></li>
						<%})%>
					</ul>
				<%}%>
			</li>
			<li class="navbar-btn">
				<div class="checkbox-inline dropdown">
					<% var org_board_count = '';
					   if(organization.attributes.board_count != 0){
						org_board_count = organization.attributes.board_count;
						org_board_count = (org_board_count > 1) ? 's' : '';
					   }
					%>
					<a title="<%- i18next.t('Boards') %>" class="btn btn-default <% if(organization.attributes.board_count != 0){ %>dropdown-toggle<%}else{%>js-no-action<%}%>" href="#" <% if(organization.attributes.board_count != 0){ %>data-toggle="dropdown"<%}%>>
						<%- i18next.t('{{count}} Board{{board_count}}', {count: organization.attributes.board_count, board_count: org_board_count}) %>
					</a>
					<% if(organization.attributes.board_count != 0){ %>
						<ul class="dropdown-menu arrow arrow-right  text-left" role="boards">
							<% _.each(organization.attributes.boards_listing, function(board){%>
							<% 	
								var style = '';		
								if (board.background_picture_url) {
									var background_picture_url = board.background_picture_url.replace("_XXXX.jpg", "_n.jpg");
									style = 'background:url(' + background_picture_url + ') 25% 25%; background-size: cover';
								} else if (board.background_pattern_url) {
									var background_pattern_url = board.background_pattern_url.replace("_XXXX.jpg", "_n.jpg");
									style = 'background:url(' + background_pattern_url + ') repeat scroll 0% 0%;';
								} else if (board.background_color){
									style = 'background-color:' + board.background_color;
								} else {
									style = '';
								}
							%>
								<li>
									<a href="#/board/<%-board.id%>">
										<span style="<%= style %>" class="preview-thumbnail"></span>
										<span class="details navbar-btn">
											<span title="<%- board.name %>" class="board-list-item-name navbar-btn"><%- board.name %></span>
										</span> 
									</a>
								</li>
							<%})%>
						</ul>
					<%}%>
				</div>
			</li>						
			<% if(!_.isUndefined(authuser.user) && (authuser.user.role_id == 1 || !_.isEmpty(organization.acl_links.where({slug: "delete_organization",organization_user_role_id: parseInt(organization_user_role_id)})))){%>
				<li class="dropdown navbar-btn pull-right">
					<a class="btn btn-primary dropdown-toggle js-show-confirm-delete-organization" data-organization_id="<%- organization.attributes.id %>" data-toggle="dropdown" href="#"><span><i class="icon-remove"></i></span><span><%- i18next.t('Delete') %></span></a>
					<ul class="dropdown-menu dropdown-menu-right arrow arrow-right col-xs-12">
						<li class="js-show-confirm-delete-organization-response js-dropdown-popup dropdown-popup"></li>
					</ul>
				</li>
			<% } else { %>
				<li class="dropdown navbar-btn pull-right">
					<a class="btn btn-primary js-no-action" disabled href="#"><span><i class="icon-remove"></i></span><span><%- i18next.t('Delete') %></span></a>
				</li>
			<% } %>
			</ul>
		</li>
		<li class="pull-right text-center">
			<ul class="list-inline navbar-btn clearfix">
				<li>
					<dl class="clearfix text-center list-group-item-heading">
						<dt>
							<div class="btn-group navbar-btn list-activity"> <a href="#" class="btn btn-default js-no-action htruncate">
							<% setInterval(function() { %>
								<% parse_date(organization.attributes.modified, authuser, 'js-timeago-activity-'+organization.attributes.id); %>
							<% }, 10000); %>
							<span class="js-timeago-activity-<%- organization.attributes.id %>"><%= parse_date(organization.attributes.modified, authuser, 'js-timeago-activity-'+organization.attributes.id, true) %></span>
							</a> </div>
						</dt>
						<dd><h6 class="text-center h4 navbar-btn"><%- i18next.t('Recent activity') %></h6></dd>
					</dl></li>
				<li>
					<dl class="clearfix text-center list-group-item-heading">
						<dt>
							<div class="btn-group navbar-btn list-activity"> <a href="#" class="btn btn-default js-no-action htruncate">
							<% setInterval(function() { %>
								<% parse_date(organization.attributes.created, authuser, 'js-timeago-'+organization.attributes.id); %>
							<% }, 10000); %>
							<span class="js-timeago-<%- organization.attributes.id %>"><%= parse_date(organization.attributes.created, authuser, 'js-timeago-'+organization.attributes.id, true) %></span>

							</a> </div>
						</dt>
						<dd><h6 class="text-center h4 navbar-btn"><%- i18next.t('Created') %></h6></dd>
					</dl>
				</li>
				<li>
					<dl class="clearfix text-center list-group-item-heading">
						<dt>
							<div class="btn-group navbar-btn list-activity"> <% if(organization.attributes.username != null){ %><a href="#/user/<%- organization.attributes.user_id %>" class="btn btn-default htruncate" title="<%- organization.attributes.username %>"><%- organization.attributes.username %></a><%}else{%>-<%}%></div>
						</dt>
						<dd><h6 class="text-center h4 navbar-btn">
							<% _.each(organization.attributes.organization_user_roles,function(organization_user_role) {
							if(organization_user_role.id === 1) { %>
								<%- i18next.t(organization_user_role.name) %></h6></dd>
							<%}
						});%>
					</dl>
				</li>
			 </ul>
		</li>
	</ul>
</td>
<%}else{%>
	<div class="alert alert-info">
		<%- i18next.t('No %s available.', { postProcess: 'sprintf', sprintf: [i18next.t('organizations')] }) %>
	</div>
<%}%>